package com.ibeeking.found.cop.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.cop.b.rest.service.IGroupQrcodeClassService;
import com.ibeeking.found.cop.b.rest.service.IGroupQrcodeService;
import com.ibeeking.found.cop.service.common.param.GroupQrcodeClassParam;
import com.ibeeking.found.cop.service.common.param.GroupQrcodeParam;
import com.ibeeking.found.cop.service.common.query.CopDepartmentQuery;
import com.ibeeking.found.cop.service.common.query.GroupQrcodeClassQuery;
import com.ibeeking.found.cop.service.common.query.GroupQrcodePageQuery;
import com.ibeeking.found.cop.service.common.query.GroupQrcodeQuery;
import com.ibeeking.found.cop.service.common.vo.CopDepartmentVO;
import com.ibeeking.found.cop.service.common.vo.GroupQrcodeClassVO;
import com.ibeeking.found.cop.service.common.vo.GroupQrcodeVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName GroupQrcodeController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/groupQrcode/v1")
public class GroupQrcodeController {

    @Resource
    private IGroupQrcodeClassService groupQrcodeClassServiceImpl;

    @Resource
    private IGroupQrcodeService groupQrcodeServiceImpl;


    /*
     *  群活码设置
     */
    /*
     ** 企业部门信息
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询活码分组列表树")
    @PostMapping(value = "/qrcodeClassTreeList/{parentId}")
    public List<GroupQrcodeClassVO> departmentTreeList(@PathVariable("parentId") Long parentId) {
        List<GroupQrcodeClassVO>  CopDepartmentVOS = groupQrcodeClassServiceImpl.listByParentId(parentId);
        return CopDepartmentVOS;
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询活码分组列表")
    @PostMapping(value = "/qrcodeClassList")
    public List<GroupQrcodeClassVO> departmentList(@RequestBody GroupQrcodeClassQuery query) {
        return groupQrcodeClassServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加群活码")
    @PostMapping(value = "/qrcodeClassAdd")
    public Boolean qrcodeClassAdd(@RequestBody @Validated(BaseValidationGroup.Insert.class) GroupQrcodeClassParam param) {
        return groupQrcodeClassServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改群活码")
    @PostMapping(value = "/qrcodeClassModify")
    public Boolean qrcodeClassModify(@RequestBody @Validated(BaseValidationGroup.Update.class) GroupQrcodeClassParam param) {
        return groupQrcodeClassServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看群活码详情")
    @GetMapping(value = "/qrcodeClassView/{id}")
    public GroupQrcodeClassVO qrcodeClassView(@PathVariable("id") Long id) {
        return groupQrcodeClassServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除群活码")
    @GetMapping(value = "/qrcodeClassDel/{id}")
    public Boolean qrcodeClassDel(@PathVariable("id") Long id) {
        return groupQrcodeClassServiceImpl.del(id);
    }

    /*
    *  群活码设置
    */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群活码列表")
    @PostMapping(value = "/qrcodeList")
    public List<GroupQrcodeVO> qrcodeList(@RequestBody GroupQrcodeQuery query) {
        return groupQrcodeServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询群活码分页列表")
    @PostMapping(value = "/qrcodePageList")
    public Page<GroupQrcodeVO> qrcodePageList(@RequestBody GroupQrcodePageQuery pageQuery) {
        return groupQrcodeServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加群活码")
    @PostMapping(value = "/qrcodeAdd")
    public Boolean qrcodeAdd(@RequestBody @Validated(BaseValidationGroup.Insert.class) GroupQrcodeParam param) {
        return groupQrcodeServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改群活码")
    @PostMapping(value = "/qrcodeModify")
    public Boolean qrcodeModify(@RequestBody @Validated(BaseValidationGroup.Update.class) GroupQrcodeParam param) {
        return groupQrcodeServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/qrcodeChangeStatus/{id}/{status}")
    public Boolean qrcodeChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return groupQrcodeServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看群活码详情")
    @GetMapping(value = "/qrcodeView/{id}")
    public GroupQrcodeVO qrcodeView(@PathVariable("id") Long id) {
        return groupQrcodeServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除群活码")
    @GetMapping(value = "/qrcodeDel/{id}")
    public Boolean qrcodeDel(@PathVariable("id") Long id) {
        return groupQrcodeServiceImpl.del(id);
    }

}
